//
//  LZVideoActivityView.m
//  laziz_Consumer
//
//  Created by xbnzd on 17/3/31.
//  Copyright © 2017年 XBN. All rights reserved.
//

#import "LZVideoActivityView.h"
#import "extobjc.h"

@interface LZVideoActivityView()
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityView;
@property (nonatomic, assign) BOOL isCancelActivity;

@end

@implementation LZVideoActivityView

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.layer.cornerRadius = 6;
    self.layer.masksToBounds = YES;
    self.isCancelActivity = NO;
}

- (void)startActivityForWaitSomeSecond:(CGFloat)someSecond
{
    @weakify(self);
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(someSecond * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        @strongify(self);
        if (self.isCancelActivity == NO) {
            self.isCancelActivity = NO;
            if (self.hidden == YES) {
                self.hidden = NO;
            }
            [self.activityView startAnimating];
        }
    });
}

- (void)stopActivity
{
    [self.activityView stopAnimating];
    self.hidden = YES;
    self.isCancelActivity = YES;
}

- (void)resetActivity
{
    self.hidden = YES;
    self.isCancelActivity = NO;
}
@end
